//
//  DZMainController.m
//  dzyc
//
//  Created by 蓝鳍互娱 on 2024/6/14.
//

#import "DZMainController.h"
#import "DZBuyVipController.h"
@interface DZMainController ()
@property (weak, nonatomic) IBOutlet UILabel *vipTimeLab;
@property (weak, nonatomic) IBOutlet UIImageView *vipHeadImgView;
@property (weak, nonatomic) IBOutlet UIImageView *vipAlertImgView;
@property (weak, nonatomic) IBOutlet UIButton *goBecomeVipBtn;
@end

@implementation DZMainController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    self.navigationController.navigationBar.hidden = YES;
    [self updataVipStatus];
}
- (void)updataVipStatus{
    NSTimeInterval time = [NSString getBuyTime];
    NSTimeInterval cureentTime = [NSString getNowTime];
    if(time&&time > cureentTime){//会员
        NSString *expiredTime = [NSString makeExpiredTime:time];
        self.vipTimeLab.text = [NSString stringWithFormat:@"会员有效期:%@",expiredTime];
        self.vipHeadImgView.hidden = false;
        self.vipAlertImgView.hidden = false;
        self.goBecomeVipBtn.hidden = true;
    }else{
        self.vipTimeLab.text = @"立即解锁全部功能";
        self.vipHeadImgView.hidden = true;
        self.vipAlertImgView.hidden = true;
        self.goBecomeVipBtn.hidden = false;
    }
}
- (IBAction)goBecomeVip:(UIButton *)sender {
    DZWeakSelf
    DZBuyVipController * buyVipCtrl = [[DZBuyVipController alloc] init];
    UINavigationController * buyVipNavCtrl = [[UINavigationController alloc] initWithRootViewController:buyVipCtrl];
//    buyVipNavCtrl.navigationBarHidden = YES;
    buyVipNavCtrl.modalPresentationStyle = UIModalPresentationOverFullScreen;
    [self presentViewController:buyVipNavCtrl animated:YES completion:^{
        
    }];
    buyVipCtrl.ApplePayBuyVipBlock = ^{
        [weakSelf updataVipStatus];
    };
    buyVipCtrl.ApplePayRepeatBuyVipBlock = ^{
        [weakSelf updataVipStatus];
    };
}
- (IBAction)userAgreement:(UIButton *)sender {
    DZWebViewController * webViewCtrl = [[DZWebViewController alloc] init];
    webViewCtrl.webUrl = DZUserAgreement;
    [self.navigationController pushViewController:webViewCtrl animated:YES];
}
- (IBAction)priveAgreement:(UIButton *)sender {
    DZWebViewController * webViewCtrl = [[DZWebViewController alloc] init];
    webViewCtrl.webUrl = DZPriveAgreement;
    [self.navigationController pushViewController:webViewCtrl animated:YES];
}
- (IBAction)icpAgreement:(UIButton *)sender {
    DZWebViewController * webViewCtrl = [[DZWebViewController alloc] init];
    webViewCtrl.webUrl = DzIcpAgreement;
    [self.navigationController pushViewController:webViewCtrl animated:YES];
}
- (IBAction)navBack:(UIButton *)sender {
    [self.navigationController popViewControllerAnimated:YES];
}
@end
